namespace Cik.Gapi4Net.Testing
{
    using Core.AcsynRequest;
    using Entlib.Logging;
    using Gapi4net.Testing.Unity.StubInstance;
    using Microsoft.Practices.ServiceLocation;
    using Microsoft.Practices.Unity;
    using Microsoft.VisualStudio.TestTools.UnitTesting;

    [TestClass]
    public abstract class TestingBase
    {
        protected IUnityContainer _container;

        [TestInitialize]
        public virtual void InitTest()
        {
            _container = new UnityContainer();
            RegisterService();
            ServiceLocator.SetLocatorProvider(() => new UnityServiceLocator(_container));
        }

        [TestCleanup]
        public virtual void EndTest()
        {
            if (_container != null)
                _container.Teardown(this);
        }

        private void RegisterService()
        {
            _container.RegisterType(typeof(IService), typeof(ServiceStub));
            _container.RegisterType(typeof(ILoggerFactory), typeof(LoggerFactory));
            _container.RegisterType(typeof(IDownloader), typeof(Downloader));
            //_container.RegisterType(typeof(IUrlBuilder<>), typeof())
        }
    }
}